home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Mac OS / Thread Manager / Sample Applications / 68k Examples / Single Intersection Threads / UInitMgmt.p < prev    next >
Encoding:
Text File  |  1994-11-17  |  4.8 KB  |  144 lines  |  [TEXT/MPS ]

  1. {–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
  2.  
  3.     PROJECT:        Threads Traffic Simulation
  4.     
  5.     FILE:            UApplication.p
  6.     
  7.     LANGUAGE:        MPW Pascal (version 3.2)
  8.         
  9.     DESCRIPTION:    This is the declaration area for all application variables and constants.  If possible,
  10.                     no procedures or functions should be put here.
  11.         
  12.     AUTHOR(S):        William H. Knott
  13.                     Apple Computer
  14.                     Cupertino, CA  95014
  15.                     AppleLink : KNOTT
  16.     
  17.     VERSION(S):        1.0        13-Oct-91    WHK    Brand New Today.
  18.  
  19. –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––}
  20.  
  21. UNIT UInitMgmt;
  22.  
  23. INTERFACE
  24.  
  25. USES
  26.     MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf, Traps,
  27.     
  28.     UApplication, UDocument, UEventMgmt;
  29.  
  30. PROCEDURE Segment_UInitMgmt;
  31. PROCEDURE InitProgram;
  32.  
  33. IMPLEMENTATION
  34.  
  35. {$S InitMgmt}
  36. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  37. {                                                                                      }
  38. {    Segment_UInitMgmt                                                                  }
  39. {                                                                                      }
  40. {    Provided as a convenient way of unloading the InitMgmt segment when needed          }
  41. {                                                                                      }
  42. {    October 13, 1991        Created by William Knott                                  }
  43. {                                                                                      }
  44. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  45. PROCEDURE Segment_UInitMgmt;
  46.     BEGIN
  47.     END;
  48.     
  49. {$S InitMgmt}
  50. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  51. {                                                                                      }
  52. {    InitToolBox                                                                          }
  53. {                                                                                      }
  54. {    When a Macintosh application first launches, certain managers need to me          }
  55. {    initialized so that the various operating system managers will function properly. }
  56. {    Also MoreMasters is called a few times to allocate a few extra master pointer      }
  57. {    blocks in the heap.  This should help with the problems of heap fragmentation      }
  58. {    since master pointer blocks are not relocatable.                                  }
  59. {                                                                                      }
  60. {    October 13, 1991        Created by William Knott                                  }
  61. {                                                                                      }
  62. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  63. PROCEDURE InitToolBox;
  64.     BEGIN
  65.         InitGraf(@thePort);
  66.         InitFonts;
  67.         InitWindows;
  68.         InitMenus;
  69.         TEInit;
  70.         InitDialogs(NIL);                    { Since NIL is passed, we have no DS error handling, so TS!    }
  71.         InitCursor;
  72.         MoreMasters;
  73.         MoreMasters;
  74.         MoreMasters;
  75.         MoreMasters;
  76.         MaxApplZone;
  77.     END;
  78.  
  79. {$S InitMgmt}
  80. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  81. {                                                                                      }
  82. {    InitApplicationVariables                                                          }
  83. {                                                                                      }
  84. {    Set the initial values of the applications globals.                               }
  85. {                                                                                      }
  86. {    October 13, 1991        Created by William Knott                                  }
  87. {                                                                                      }
  88. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  89. PROCEDURE InitApplicationVariables;
  90.     BEGIN
  91.         gClipboard := NIL;                { Will create clipboard when it is needed.                }
  92.         gDone := FALSE;                    { Set to TRUE when program is to terminate.                }
  93.         InitDocumentGlobals;            { Initialize globals dealing with document management    }
  94.         gAutomobiles := NIL;
  95.     END;
  96.     
  97. {$S InitMgmt}
  98. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  99. {                                                                                      }
  100. {    InitMenuBar                                                                          }
  101. {                                                                                      }
  102. {    By using the MBAR resource we are able to define which menus will be included      }
  103. {    in the menu bar nonprogramatically.  In this way, menus can be easily modified      }
  104. {    without major code changes being needed.  Also the Apple Menu needs to be treated }
  105. {    differnetly since we will be adding all of the desk accessories to it.              }
  106. {                                                                                      }
  107. {    October 13, 1991        Created by William Knott                                  }
  108. {                                                                                      }
  109. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  110. PROCEDURE InitMenuBar;
  111.     VAR
  112.         CurMBar    : Handle;
  113.         AppleMenu    : MenuHandle;
  114.     BEGIN
  115.         CurMBar := GetNewMBar(rMenuBarID);
  116.         SetMenuBar(CurMBar);
  117.         DisposHandle(CurMBar);
  118.         AppleMenu := GetMHandle(rAppleMenuID);
  119.         AddResMenu(AppleMenu,'DRVR');
  120.         SetMenuBarState;
  121.         DrawMenuBar;
  122.     END;
  123.     
  124. {$S InitMgmt}
  125. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  126. {                                                                                      }
  127. {    InitProgram                                                                          }
  128. {                                                                                      }
  129. {    Setup everything that the application needs to run.  Firstly initialize all of      }
  130. {    the toolbox managers, then set the application variables to their preset values.  }
  131. {    Lastly, get the menu bar and display it.                                          }
  132. {                                                                                      }
  133. {    October 13, 1991        Created by William Knott                                  }
  134. {                                                                                      }
  135. {––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-––}
  136. PROCEDURE InitProgram;
  137.     BEGIN
  138.         InitToolBox;
  139.         InitApplicationVariables;
  140.         InitMenuBar;
  141.     END;
  142.     
  143.  
  144. END.